"""
@-*- coding: utf-8 -*-
@ python: 3.12.3
@ 创建者: JacksonCode
@ 创建时间: 2025-11-07
"""
from flask import Flask
from app.extensions import db
from config import Config
from app.routes.user_routes import user_bp


def create_app():
    app = Flask(__name__)
    app.config.from_object(Config)

    db.init_app(app)

    # 注册蓝图
    app.register_blueprint(user_bp)

    # 添加 cli命令

    @app.cli.command()
    def init_db():
        """ Initialize the database """
        ###cmd flask --app run.py init-db
        db.create_all()
        print("Database Initialized")

    return app
